using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;
using System.Collections;
using System.Security.Principal;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.ApplicationBlocks.Data;
using Microsoft.AceEngineering.SPM.SPMBusinessLayer;
using Microsoft.AceEngineering.SPM.SPMCustomDataEntity;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string alias = Session["loginname"].ToString();
        lblname.Text = Microsoft.Security.Application.AntiXss.HtmlEncode(alias);
        pnlAdminNav.Visible = UsersBL.GetUserAdmin(alias);
    }
    private string GiveMeAlias(string domainAndAlias)
    {
        domainAndAlias = domainAndAlias.ToLower();
        char[] strSeperator = new char[] { '\\' };
        string[] aryAuthUser = new string[2];
        aryAuthUser = domainAndAlias.Split(strSeperator);
        return aryAuthUser[1];
    }

    private void ValidateUser()
    {
        string currAlias = GiveMeAlias(HttpContext.Current.User.Identity.Name);
        UserCDE user = UsersBL.ValidateUser(currAlias);
        if (user.Active)
        {
            Session["user"] = user;
            Session["loginname"] = user.UserAlias;
        }
        else
        {
            Response.Redirect(Request.ApplicationPath + "/Errors/NoAccess.htm");
        }
    }

    #region Navigation Clicks

    protected void lbnHome_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Home.aspx"); 
    }
    protected void lbnEntry_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Application/ApplicationDataEntry.aspx");
    }
    protected void lbnSearch_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Application/Search.aspx");
    }
    protected void lbnRisk_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Workflow/Default.aspx");
    }
    protected void lbnStatus_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Workflow/Tasks.aspx");
    }
    protected void lbnUsers_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/Users/Users.aspx");
    }
    protected void lbnTypes_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/ContactTypes.aspx");
    }
    protected void lbnOrg_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/Organization.aspx");
    }
    protected void lbnAssessment_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/Risk/Categories.aspx");
    }
    protected void lbnAttributes_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/ManageAttributes.aspx");
    }
    protected void lbnRanges_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/ManageScoreRanges.aspx");
    }
    protected void lbnWorkflow_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/Workflow/Workflow.aspx");
    }
    protected void lbnMapping_Click(object sender, EventArgs e)
    {
        Session["search"] = null;
        Response.Redirect("~/Admin/Workflow/TaskMapping.aspx");
    }
    #endregion

}
